{extend name="layouts/main" /}
{block name="link"}{/block}
{block name="content"}
<div class="layui-layout layui-layout-admin">
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
	<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
		<div class="layui-body layui-tab-content site-demo site-demo-body" style="top: 0px;left: 0px;">
			<div class="layui-tab-item layui-show">
				<div class="layui-main">
					<div id="LAY_preview">
						<blockquote class="layui-elem-quote layui-text" style="margin-bottom: 5px;">
							<i class="fa fa-home"></i>
							<span class="layui-breadcrumb">
								<a><cite>系统主页</cite></a>
								<a><cite>{$meta_title}</cite></a>
							</span>
						</blockquote>
						<div class="layui-fluid" style="position: relative;margin: 0 auto;padding: 0 0px;">
							<div class="layui-set">
								<div class="layui-set-from search-form">
									<form class="layui-form" action="">
										<div class="layui-form-item" style="margin-bottom: -8px;">
											<div class="layui-input-inline" style="margin-right: 5px;">
												<select name="status" lay-verify="required">
													<option value="" selected="selected">状态</option>
													<option value="1">启用</option>
													<option value="0">禁用</option>
												</select>
											</div>
											<div class="layui-input-inline" style="margin-right: 5px;">
												<select name="group_id" lay-verify="required">
													<option value="" selected="selected">分组</option>
													{volist name=":get_field_group()" id="group"}
													<option value="{$key}">{$group}</option>
													{/volist}
												</select>
											</div>
											<div class="layui-input-inline" style="margin-right: 5px;">
												<input type="hidden" name="model_id" value="{$model_id}">
												<input type="text" name="title" value="{:input('title')}"  placeholder="搜索关键词" autocomplete="off" class="layui-input search-input">
											</div>
											<div class="layui-input-inline" style="width:51px">
												<button class="layui-btn" id="search" style="height: 36px;"><i class="layui-icon"></i></button>
											</div>
											<!-- <div class="layui-input-inline" style="width:131px;margin-right: 14px;">
												<a class="layui-btn layui-btn-warm ajax-get" href="{:url('Common/update_cache',array('type'=>'attribute'))}">
													<i class="layui-icon">စ</i>更新模型字段缓存
												</a>
											</div> -->
										</div>
									</form>
								</div>
							</div>
							<div class="layui-card" style="overflow-y: hidden;float: left;width: 100%;">
								<form class="layui-form" action="">
									<table class="layui-table" lay-filter="tableEvent">
										<colgroup>
											<col width="1">
											<col width="5%">
											<col width="6%">
											<col>
											<col>
											<col>
											<col width="8%">
											<col width="20%">
										</colgroup>
										<thead>
											<tr>
												<th><input type="checkbox" lay-skin="primary" id="allChoose" lay-filter="allChoose"></th>
												<th>ID</th>
												<th>序号</th>
												<th>字段</th>
												<th>名称</th>
												<th>数据类型</th>
												<th>状态</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody>
											{volist name="list" id="info"}
											<tr>
												<td><input type="checkbox" lay-skin="primary" class="ids" name="ids[]" value="{$info.id}" lay-filter="c_one"></td>
												<td>{$info.id}</td>
												<td><input type="text" name="sort[{$info.id}]" value="{$info.sort}" class="layui-input sort" lay-filter="weight"></td>
												<td>{$info.name}</td>
												<td>{$info.title}</td>
												<td>{:get_attribute_type($info.type)}</td>
												<td>
													<!-- {$info.status_text} -->
													<input type="checkbox" class="switch" {if condition="$info['status'] eq 1"} checked="" {/if} url="{:url('setStatus')}" on="ids={$info.id}&status=1" off="ids={$info.id}&status=0" lay-skin="switch" lay-filter="switchTest" lay-text="正常|禁止">
												</td>
												<td>
													<div class="layui-inline"><a class="layui-btn layui-btn-xs " href="javascript:;" onclick="x_admin_show('编辑-{:get_model_by_id($model_id)}-字段','{:url('edit',array('id'=>$info['id'],'model_id'=>$info['model_id'],'table_name'=>$info['table_name']))}','','',1)"><i class="layui-icon layui-icon-edit"></i> 编辑</a></div>
													{if condition="$info['status'] eq 0"}
													<div class="layui-inline"><a class="layui-btn layui-btn-xs layui-btn-normal ajax-get" url="{:url('setStatus',array('ids'=>$info['id'],'status'=>1))}"><i class="layui-icon layui-icon-release"></i> 启用</a></div>
													{else/}
													<div class="layui-inline"><a class="layui-btn layui-btn-xs layui-btn-warm ajax-get" url="{:url('setStatus',array('ids'=>$info['id'],'status'=>0))}"><i class="layui-icon layui-icon-set-fill"></i> 禁用</a></div>
													{/if}
													<div class="layui-inline"><a class="layui-btn layui-btn-xs layui-btn-danger confirm ajax-get" url="{:url('del',array('ids'=>$info['id']))}"><i class="layui-icon layui-icon-delete"></i> 删除</a></div>
												</td>
											</tr>
											{/volist}
											<tr>
												<td align="left" colspan="10" style="padding-left:0;">
													&nbsp;
													<div class="layui-inline"><a href="javascript:;" onclick="x_admin_show('新增-{:get_model_by_id($model_id)}-字段','{:url('add',['model_id'=>$model_id,'table_name'=>$table_name])}','','',1)" title="新增" class="layui-btn layui-btn-sm">新增</a></div>
													<div class="layui-inline"><a href="" class="layui-btn layui-btn-sm ajax-post" target-form="sort" url="{:url('sort')}" title="排序">排序</a></div>
													<div class="layui-inline"><a href="" class="layui-btn layui-btn-sm layui-btn-normal ajax-post" target-form="ids" url="{:url('setStatus',array('status'=>1))}">正常</a></div>
													<div class="layui-inline"><a href="" class="layui-btn layui-btn-sm layui-btn-warm ajax-post" target-form="ids" url="{:url('setStatus',array('status'=>0))}">禁用</a></div>
													<div class="layui-inline"><a href="" class="layui-btn layui-btn-sm layui-btn-danger confirm ajax-post" target-form="ids" url="{:url('del')}">删除</a></div>
												</td>
											</tr>
										</tbody>
									</table>
								</form>
								<!-- <div id="page">
									<div class="layui-box layui-laypage layui-laypage-default">
										<div class="pagelistbox">
											<span>共 2 页/31条记录 </span>
											<span class="indexPage">首页 </span>
											<strong>1</strong>
											<a href="#">2</a>
											<a class="nextPage" href="#">下页</a>
											<a class="endPage" href="#">末页</a>
										</div>
									</div>
								</div> -->
								<!-- <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-10"><span class="layui-laypage-prev">共 2 页/31条记录</span><a href="javascript:;" class="layui-laypage-prev" data-page="1">首页</a><a href="javascript:;" class="layui-laypage-prev" data-page="1">上一页</a><a href="javascript:;" data-page="1">1</a><span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>2</em></span><a href="javascript:;" data-page="3">3</a><a href="javascript:;" data-page="4">4</a><a href="javascript:;" data-page="5">5</a><span class="layui-laypage-spr">…</span><a href="javascript:;" class="layui-laypage-last" title="尾页" data-page="10">10</a><a href="javascript:;" class="layui-laypage-next" data-page="3">下一页</a><a href="javascript:;" class="layui-laypage-next" data-page="3">尾页</a><a href="javascript:;" data-page="2" class="layui-laypage-refresh"><i class="layui-icon layui-icon-refresh"></i></a><span class="layui-laypage-skip">到第<input type="text" min="1" value="2" class="layui-input">页<button type="button" class="layui-laypage-btn">确定</button></span></div> -->
								<div id="page">
									<div class="layui-box layui-laypage layui-laypage-default">
										<div class="pagelistbox">
											{$list|raw}
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript">
	$(function() {
		$("select[name='status']").val({$status|default = ''});
		$("select[name='group_id']").val({$group_id|default = ''});
	});
</script>
{/block}
